import com.it.rabbitQM.RabbitMQProducerMain;
import org.junit.jupiter.api.Test;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

/**
 * projectName: spring_boot_RabbitQM
 *
 * @author: 王宝贵
 * time: 2024/9/10 19:13 周二
 * description: Topic通配符模式
 */
@SpringBootTest(classes = RabbitMQProducerMain.class)
public class RabbitMQ004 {


    @Autowired
    private RabbitTemplate rabbitTemplate;

    public static final String EXCHANGE_TOPIC = "com.exchange.topic";
    public static final String ROUTING_KEY_ERROR = "#.error";
    public static final String ROUTING_KEY_ORDER = "order.*";
    public static final String ROUTING_KEY_ALL = "*.*";

    @Test
    public void testSendMessageTopic() {


        for (int i = 0; i < 10; i++) {
            rabbitTemplate.convertAndSend(EXCHANGE_TOPIC, "goods.info", "message goods info ..." +i);
            rabbitTemplate.convertAndSend(EXCHANGE_TOPIC, "order.info", "message order info ...");
        }

       // rabbitTemplate.convertAndSend(EXCHANGE_TOPIC, "goods.error", "message goods error ...");
    }
}